# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=oslo-config
pkgbase=mingw-w64-python-${_realname}
pkgname=( "${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=9.8.0
pkgrel=1
pkgdesc="parsing command line arguments and .ini style configuration files (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-oslo-config'
  'purl: pkg:pypi/oslo-config'
)
msys2_repository_url='https://opendev.org/openstack/oslo.config/'
msys2_changelog_url='https://docs.openstack.org/releasenotes/oslo.config/'
msys2_documentation_url='https://docs.openstack.org/oslo.config/latest/'
msys2_issue_tracker_url='https://bugs.launchpad.net/oslo.config'
url='https://docs.openstack.org/oslo.config/latest/'
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python-debtcollector"
         "${MINGW_PACKAGE_PREFIX}-python-netaddr"
         "${MINGW_PACKAGE_PREFIX}-python-stevedore"
         "${MINGW_PACKAGE_PREFIX}-python-oslo-i18n"
         "${MINGW_PACKAGE_PREFIX}-python-requests"
         "${MINGW_PACKAGE_PREFIX}-python-rfc3986"
	 "${MINGW_PACKAGE_PREFIX}-python-yaml")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-pbr")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-oslotest"
              "${MINGW_PACKAGE_PREFIX}-python-sphinx"
              "${MINGW_PACKAGE_PREFIX}-python-requests-mock"
              "${MINGW_PACKAGE_PREFIX}-python-oslo-log")
options=(!strip)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname/-/_}/${_realname/-/_}-${pkgver}.tar.gz")
sha256sums=('eea8009504abee672137c58bdabdaba185f496b93c85add246e2cdcebe9d08aa')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname/-/_}-${pkgver}" "python-build-${MSYSTEM}"

  export PBR_VERSION=$pkgver
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  PYTHON=${MINGW_PREFIX}/bin/python ${MINGW_PREFIX}/bin/stestr run || warning "Tests failed"
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
